<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
   <title>FishVideo</title>
   <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
   <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
   <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
</head>
<style>
	.content{
		width:90%;
		height:400px;
		margin-left:5%;
	}
	.left{
		float:left;
		width:60%;
		height:100%;
		margin-left:5%;
	}
	.right{
		width:30%;
		padding-top:5%;
		height:90%;
		margin-left:65%;
	}
	#pf{
		width:50%;
		margin-left:25%;
		font-size:30px;
	}
	#intro{
		width:90%;
		margin-left:5%;
	}
	#jqjj{
		width:50%;
		margin-left:35%;
	}
	#message_content{
		width: 90%;
	    margin-left: 10%
	}
	#message_title{
		width:50%;
		margin-left:35%;
	}
	.messagebox{
		width: 90%;
		margin-left:5%;
	}
    .usermessage{
    	width:30%;
    	float:right;
    }
	#fbly{
		width:90%;
		margin-left: 5%;
	}
	#fbutton{
		float:right;
		margin-right:2%;
	}
     #footer{
			width:100%;
			text-align:center;
	   }
</style>
<body>
   <?php require_once("daohangmenu.php");?>
<!-- 显示信息部分-->
<?php
		require_once("../utils/db.php");//链接信息\
		$link=connect();
			$benvid=$_GET['vid'];

				$sql="select * from fishvideo_video where yjl_vid='{$benvid}';"; 				
				$result = mysql_query($sql);
				$row = mysql_fetch_array($result);//所有信息的结果
				
				$sql="select yjl_typename from fishvideo_videotype where yjl_tid='{$row['yjl_tid']}';";//查询分类名称
				$typename = mysql_query($sql);
				$typename=mysql_fetch_array($typename);
				$typename=$typename['yjl_typename'];
				
				$sql="select avg(yjl_score) from fishvideo_scores where yjl_vid='{$benvid}';";
				$score=mysql_query($sql);//得到分数
				$score=mysql_fetch_array($score);
		        $score=$score[0];
				
				$sql="select yjl_adminname from fishvideo_admins where yjl_adminid='{$row['yjl_uploadadmin']}';";
				$adminname=mysql_query($sql);
				$adminname=mysql_fetch_array($adminname);
		        $adminname=$adminname['yjl_adminname'];
				
				//var_dump($row);

				if(isset($_POST['fbsub'])){//添加评论
					$sql="insert into fishvideo_comments values(null,'{$_POST['comment']}',NOW(),
					'{$_SESSION['userid']}','{$benvid}')";
					//echo $sql;
					if(!$result = mysql_query($sql)){
						echo "评论失败！";//评论失败
					}
					$sql="insert into fishvideo_scores values(null,'{$benvid}','{$_SESSION['userid']}','{$_POST['pingfen']}',NOW())";
					//echo $sql;
					if(!$result = mysql_query($sql)){
						echo "评分失败！";//评论失败
					}
				}else{
$sql="update fishvideo_video set yjl_clicktimes=yjl_clicktimes+1 where yjl_vid='{$benvid}'";
			if(!$result = mysql_query($sql)){
				echo "更新失败！";//点击次数更新
			}
			//echo "这里不应该出现！！";
		}
	?>
<div class="content">
	<div class="left">
		<video width="100%" height="90%" controls="controls">
		<source src='upload/<?php
			echo $row['yjl_address'];
		?>' type="video/mp4" codecs="avc1.42E01E, mp4a.40.2"></video>
		<div id="pf"><p>评分:<?php 
			if(!$score){
					echo "暂无评分";
			}else{
				echo round($score,2);
			}
		?></p></div>
	</div>
	<div class="right">
		<table class="table">
			<caption><h3>影片信息</h3></caption>
			<?php 
			$arrName=array("上传时间","点击次数","下载次数");
			$arr=array("yjl_uploaddate","yjl_clicktimes","yjl_downtimes");
			echo "<tr><th>影片名称</th><td>{$row['yjl_videoname']}</td></tr>";
			echo "<tr><th>分类</th><td>{$typename}</td></tr>";
			echo "<tr><th>上传人</th><td>{$adminname}</td></tr>";
			for($i=0;$i<count($arr);$i++){
				echo "<tr><th>{$arrName[$i]}</th><td>{$row[$arr[$i]]}</td></tr>";
			}
			
			echo "<tr><th>下载链接</th><td><a href='upload/downloadfile.php?filename={$row['yjl_address']}&vid={$row['yjl_vid']}' >点击下载</a></td></tr>";
			/*echo "<tr><th>下载链接</th><td><a href='downloadfile.php?filname={$row['yjl_address']}>点击下载</a></td></tr>";*/
			?>
		</table>
	</div>
</div>

<div id="intro">
	<hr>
	<div id="jqjj"><h3>剧情简介</h3></div>
	<div>
		<p><?php echo $row['yjl_intro'];?></p>
	</div>
	
</div>
<div class="message_content">
	<div id="message_title"><h3>用户影评</h3></div>
	<?php
		$sql="select * from fishvideo_comments where yjl_vid='{$benvid}'";
		 
		$result=mysql_query($sql);
		$num=mysql_num_rows($result);
		if(!$num){
			 echo "<div class='messagebox'>
				 <div class='form-control' rows='3' cols='20'>
				 还没有人对次发表评论哦！抢个沙发吧！</div>
				 <div class='usermessage'>
				 <a>酷酷的程序员   ||  </a><a>".date("y-m-d h:i:s",time())."</a>
				 </div>
				 </div><hr>";
		}
			while($row=mysql_fetch_array($result)){//所有评论
				$sql="select yjl_uname from fishvideo_users where yjl_uid='{$row['yjl_uid']}'";
				$rs=mysql_query($sql);
				$sql="select yjl_score from fishvideo_scores where yjl_uid='{$row['yjl_uid']}' and yjl_vid='{$_GET['vid']}' and yjl_pdate='{$row['yjl_cdate']}'";
				//echo $sql;
				$re=mysql_query($sql);
				if($rs){
					$cname=mysql_fetch_array($rs);
					$cname=$cname[0];

					$vscore=mysql_fetch_array($re);
					$vscore=$vscore[0];
				 echo "<div class='messagebox'>
				 <div class='form-control' rows='3' cols='20'>{$row['yjl_content']}</div>
				 <div class='usermessage'>
				 <a>评分：{$vscore} ||　</a><a>{$cname}   ||  </a><a>{$row['yjl_cdate']}</a>
				 </div>
				 </div><hr>";
				}
			} 			
	?>
</div>
	<div id='fbly'><!-- 发表留言-->
	<?php
		if(isset($_SESSION['userid'])){
			echo "<form  method='POST'>
			<textarea name='comment' class='form-control' rows='3' cols='20'
				placeholder='在这里发表评论'></textarea>

			<div id='fbutton' required='required'>
			评分<select name='pingfen'>
				<option value='1'>1</option>
				<option value='2'>2</option>
				<option value='3'>3</option>
				<option value='4' selected >4</option>
				<option value='5'>5</option>
			</select>
			<input type='submit' name='fbsub' class='btn btn-primary' value='发表评论'>
			</div>
			</form>
		</div>";
		}else{
		  echo "您可以选择<a href='#' data-toggle='modal'  data-target='#login'><h3>登录</h3></a>发表评论以及评分！";
		}
		mysql_close($link);
	?>
	<hr>
	<div id="footer">
	<p>Copyright © 2016-2017 FishVideo.com All Rights Reserved</p>
	<p>站长邮箱:574153393@qq.com</p>
</div>
</div>
</body>
</html>